package com.wenyu.wenyuyuedu.activity.personage;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wenyu.wenyuyuedu.R;
import com.wenyu.wenyuyuedu.bean.homepager.CommentBean;
import com.wenyu.wenyuyuedu.global.ApiWrapper;
import com.wenyu.wenyuyuedu.server.personage.CommonIssunServer;
import com.wenyu.wenyuyuedu.utils.StatusBarUtil;

import butterknife.ButterKnife;
import butterknife.InjectView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/*常见问题*/
public class CommonIssunActivity extends AppCompatActivity {


    @InjectView(R.id.playtour_left)
    ImageView playtourLeft;
    @InjectView(R.id.iv_common)
    ImageView ivCommon;
    private Activity activity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_common_issun);
        this.activity = CommonIssunActivity.this;
        ButterKnife.inject(this);
        StatusBarUtil.setStatusBar(CommonIssunActivity.this, R.color.white);
        initView();
      //  requestData();
    }

    /*初始化网络数据*/
    private void requestData() {
        CommonIssunServer commonIssunServer = ApiWrapper.getInstance().create(CommonIssunServer.class);
        Call<CommentBean> common = commonIssunServer.getCommon();
        common.enqueue(new Callback<CommentBean>() {
            @Override
            public void onResponse(Call<CommentBean> call, Response<CommentBean> response) {
                CommentBean body = response.body();
                if (body != null) {
                    int code = body.getCode();
                    if (code == 1) {
                        if (!body.getInfo().equals("")) {
                            Glide.with(activity)
                                    .load(Uri.parse(body.getInfo()))
                                    .error(R.drawable.default_data_photo)
                                    .into(ivCommon);
                        }
                    }

                }
            }

            @Override
            public void onFailure(Call<CommentBean> call, Throwable t) {

            }
        });
    }

    /*初始化控件*/
    private void initView() {
        playtourLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
